<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增素材专辑')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-album-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">相册名称：</label>
                <div class="col-sm-8">
                    <input name="albumName" class="form-control" required type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">编码：</label>
                <div class="col-sm-8">
                    <input name="code" class="form-control" required type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">相册类型：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('album_type')}">
                        <input type="radio" th:id="${'albumType_' + dict.dictCode}" name="albumType" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'albumType_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>


            <div class="form-group" id="div_cover" style="display: none;">
                    <label class="col-sm-3 control-label">封面图片：</label>
                    <div class="col-sm-8">

                        <div class="input-group">
                            <input id="materialPath" name="coverImage" readonly="true" onclick="selectImage()"  class="form-control valid" type="text">
                            <span class="input-group-addon"><i class="fa fa-search"></i></span>
                        </div>

                    </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">启用评论：</label>
                <div class="col-sm-8">
                    <label class="toggle-switch switch-solid">
                        <input type="hidden" id="commentFlag" name="commentFlag" required value="">
                        <input type="checkbox" id="commentFlag_show" checked>
                        <span></span>
                    </label>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label">宽度：</label>
                <div class="col-sm-8">
                    <input name="width" class="form-control"  type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">高度：</label>
                <div class="col-sm-8">
                    <input name="height" class="form-control"  type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">描述：</label>
                <div class="col-sm-8">
                    <textarea name="description" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">审核状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('audit_state')}">
                        <input type="radio" th:id="${'auditState_' + dict.dictCode}" name="auditState" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'auditState_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">

        $('[name=albumType]').on('ifChecked', function(event){
            showHideValue();
        });

        function showHideValue(){
            var v=$("[name=albumType]:checked").val();
           
            if(v=="album"){//相册
                $("#div_cover").show();
                $("#coverImage").attr("required","required");
            }else{//banner
                $("#div_cover").hide();
                $("#coverImage").removeAttr("required");
            }
        }

        var prefix = ctx + "cms/album"
        $("#form-album-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-album-add').serialize());
            }
        }
        function selectImage() {
            var url=ctx+"cms/material/selectMaterialWithGroup";
            $.modal.open("封面图片选择",url);
        }

        $("#commentFlag_show").on("change",function(){
            var v=$(this).prop("checked");
            if(v){
                $("#commentFlag").val("1");

            }else{
                $("#commentFlag").val("0");

            }
        });


    </script>
</body>
</html>